Fix glitch in SpringBoneSimulator3D
by storing the previous frame's rotation instead of using no rotation when the axis is flipped
#101651
+14
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The SkeletonModifier discards the bone pose after skin rendered, so no rotation in the next frame means the pose is not affected by that SkeletonModifier at all. In order to keep the previous pose, the SkeletonModifier needs to store the previous frame's state by itself.
When axis is flipped, currently SpringBoneSimulator returns no rotation
Quaternion(0, 0, 0, 1)
, which makes it glitchy because it means resetting the pose.fix01.mp4
This PR allows the SpringBoneSimulator to store the previous frame's rotation. Then, if the rotation axis may be inverted, it doesn't move and prevents glitches. For further stability, a check for inversion by dot product has been added.
Without checking dot product (The right most shakes for a moment):
fix02.mp4
With checking dot product (Current PR):
fix03.mp4